<!--
Copyright 2017 Google Inc. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License
is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
or implied. See the License for the specific language governing permissions and limitations under
the License.
-->

<link rel="import" href="../../bower_components/polymer-decorators/polymer-decorators.html">
<link rel="import" href="../../bower_components/app-route/app-location.html">
<link rel="import" href="../../bower_components/app-route/app-route.html">
<link rel="import" href="../../bower_components/iron-pages/iron-pages.html">

<link rel="import" href="../../components/project-picker-dialog/project-picker-dialog.html">
<link rel="import" href="../../components/datalab-notification/datalab-notification.html">
<link rel="import" href="../../components/datalab-sidebar/datalab-sidebar.html">
<link rel="import" href="../../components/datalab-toolbar/datalab-toolbar.html">
<link rel="import" href="../../components/resizable-divider/resizable-divider.html">
<link rel="import" href="../../modules/api-manager/api-manager.html">
<link rel="import" href="../../modules/file-manager-factory/file-manager-factory.html">
<link rel="import" href="../../modules/settings-manager/settings-manager.html">
<link rel="import" href="../../modules/template-manager/template-manager.html">

<dom-module id="datalab-app">
  <template>
    <style include="datalab-shared-styles">
      :host {
        background-color: var(--primary-bg-color);
      }
      #container {
        height: 100%;
        display: flex;
        flex-direction: column;
      }
      datalab-toolbar {
        flex: 0 0 var(--toolbar-height);
      }
      .datalab-contents {
        display: flex;
        flex: 1 1 auto;
      }
      .datalab-sidebar {
        flex: 0 0 var(--sidebar-width);
        transition: flex-basis var(--app-animation-duration);
      }
      .datalab-main-content {
        flex: 1 1 auto;
        /* Resizing doesn't always work properly without a non-auto min-width. */
        min-width: 100px;
        box-shadow: -4px 0px 10px -3px var(--box-shadow-color);
        z-index: 0;
      }
      iron-pages {
        height: 100%;
      }
      .page {
        height: 100%;
      }
      @media only screen and (max-width: 800px) {
        .datalab-sidebar {
          flex-basis: var(--collapsed-sidebar-width);
        }
      }
    </style>

    <!--Router-->
    <app-location route="{{route}}"></app-location>
    <app-route
        route="{{route}}"
        pattern="/:page"
        data="{{routeData}}"
        tail="{{routeTail}}"></app-route>

    <div id="container">
      <datalab-toolbar></datalab-toolbar>
      <div class="datalab-contents">
        <datalab-sidebar class="datalab-sidebar" page={{page}}></datalab-sidebar>
        <div class="datalab-main-content">
          <iron-pages id="pages" selected="{{page}}" attr-for-selected="name">
            <!-- Elements here must implement the DatalabPageElement interface -->
            <data-browser class="page" name="data" file-id="{{fileId}}"></data-browser>
            <file-browser class="page" name="files" file-id="{{fileId}}"
                          file-manager-type-list="{{_fileBrowserSources}}"></file-browser>
            <datalab-sessions class="page" name="sessions"></datalab-sessions>
            <datalab-terminal class="page" name="terminal"></datalab-terminal>
            <datalab-docs class="page" name="docs"></datalab-docs>
          </iron-pages>
        </div>
      </div>
    </div>

    <datalab-notification></datalab-notification>

  </template>
</dom-module>

<script src="datalab-app.js"></script>
